<?php

	function http($type,$arr){
			echo("type:".$type."\n");
			print_r($arr);
	}

	function upload($arr){
		$len = count($arr);
		echo("[".$len."]-----------------------------\n");
		if($len == 0){
			return;
		}
		else if($len == 1){
			http(1,$arr);
			http(3,array());
		}
		else{
			$type = 1;
			$group_max = $len - 1;
			$gourp_count = max(1,min($group_max,10));
			
			for ($i=0; $i < $len ; $i = $i + $gourp_count) { 
				if($i + $gourp_count >= $len){
					$type = 3;
				}
				echo("type:".$type." arr[".$i.",".$gourp_count."]\n");
				http($type,array_slice($arr,$i,$gourp_count));
				if($type == 1) $type = 2;
			}
		}
	}

	function main(){
		$arr = array();
		upload($arr);
		for ($i=0; $i < 3 ; $i++) { 
			array_push($arr,"cam".$i);
			upload($arr);
		}
	}

	function test(){
		$arr_cams = array("cam1","cam2","cam3");
		array_push($arr_cams,"cam4");
		array_push($arr_cams,"cam5","cam6");
		array_push($arr_cams,"cam7","cam8","cam9");
		$arr_length = count($arr_cams);
		echo "$arr_length\n";
		for ($i=0 ; $i < $arr_length  ; $i++ ) { 
			echo "$arr_cams[$i]\n";
		}
		foreach ($arr_cams as $key => $value) {
			echo "$key => $value\n";
		}
		echo "$arr_cams\n";
		print_r($arr_cams);
		echo "Hello world!\n";
	}

	main();
	
?>
